package com.usdt.system.service.impl.cp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.alibaba.fastjson2.JSON;
import com.usdt.common.core.redis.RedisClient;
import com.usdt.system.cp.utils.UserAndDeptUtils;
import com.usdt.system.domain.resp.SalesUserMonthCountRespVO;
import com.usdt.system.domain.resp.SignUserRespVo;
import com.usdt.system.mapper.cp.SalesCountMapper;
import com.usdt.system.service.cp.AsyncService;
import com.usdt.system.service.cp.RequestManageService;

@Service
public class AsyncServiceImpl implements AsyncService{
	
	private final String SINGN_USER = "/api-v1/contract/signUser/list";// 获取首签api
	
	@Autowired
	private SalesCountMapper salesCountMapper;
	
	@Autowired
	private RequestManageService requestManageService;
	
	@Autowired
	private RedisClient redisClient;

    @Async // 自动使用名为"taskExecutor"的线程池
    //@Async("cpuBoundExecutor")  // 指定使用CPU密集型线程池
    public CompletableFuture<Integer> test() {
        // 模拟耗时操作
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return CompletableFuture.completedFuture(10);
    }

	@Override
	@Async("taskExecutor")
	public CompletableFuture<List<SalesUserMonthCountRespVO>> getClueUserMonthCount(String startDate, String endDate, List<String> deptIds) {
        try {
            List<SalesUserMonthCountRespVO> clueUserMonthCount = salesCountMapper.getClueUserMonthCount(startDate,endDate,deptIds);
            return CompletableFuture.completedFuture(clueUserMonthCount);
        } catch (Exception e) {
        	System.out.println(e);
            return CompletableFuture.completedFuture(new ArrayList<SalesUserMonthCountRespVO>());
        }
	}

	@Override
	@Async("taskExecutor")
	public CompletableFuture<List<SalesUserMonthCountRespVO>> getVisitUserMonthCount(String startDate, String endDate,
			List<String> deptIds) {
		try {
            List<SalesUserMonthCountRespVO> clueUserMonthCount = salesCountMapper.getVisitUserMonthCount(startDate,endDate,deptIds);
            return CompletableFuture.completedFuture(clueUserMonthCount);
        } catch (Exception e) {
        	System.out.println(e);
            return CompletableFuture.completedFuture(new ArrayList<SalesUserMonthCountRespVO>());
        }
	}
	
	@Override
	@Async("taskExecutor")
	public CompletableFuture<List<SalesUserMonthCountRespVO>> getSignUserMonthCount(String currentUserId, String currentDeptId,String startDate, String endDate, List<String> deptIds) {
		try {
    		//cp查询签约人员
    		String resp = this.getSignUserData(currentUserId,currentDeptId,startDate,endDate,deptIds);
    		if(StringUtils.isBlank(resp)) {
    			return CompletableFuture.completedFuture(new ArrayList<SalesUserMonthCountRespVO>());
    		}
    		List<SignUserRespVo> signUserList = JSON.parseObject(resp).getList("data",SignUserRespVo.class);
    		if(CollectionUtils.isEmpty(signUserList)) {
    			return CompletableFuture.completedFuture(new ArrayList<SalesUserMonthCountRespVO>());
    		}
    		
    		List<SalesUserMonthCountRespVO> result = new ArrayList<SalesUserMonthCountRespVO>();
    		//根据人分组
    		Map<String, List<SignUserRespVo>> map = signUserList.stream().collect(Collectors.groupingBy(SignUserRespVo::getUserId));
    		map.forEach((k,v)->{
    			Map<String, List<SignUserRespVo>> map2 = v.stream().collect(Collectors.groupingBy(SignUserRespVo::getStartDateTemp));
    			map2.forEach((ke,vu)->{
    				SalesUserMonthCountRespVO salesUserMonth = new SalesUserMonthCountRespVO();
    				salesUserMonth.setUserId(k);
    				salesUserMonth.setUserName(v.get(0).getUserName());
    				salesUserMonth.setMonth(ke);
    				salesUserMonth.setCount(vu.size());
    				result.add(salesUserMonth);
    			});
    		});	
            return CompletableFuture.completedFuture(result);
        } catch (Exception e) {
        	System.out.println(e);
            return CompletableFuture.completedFuture(new ArrayList<SalesUserMonthCountRespVO>());
        }
	}
	
	/**cp云应用接口查询首签客户信息
	 * 
	 */
	@Override
	public String getSignUserData(String currentUserId, String currentDeptId,String startDate, String endDate, List<String> deptIds) {
		
		//String st = "{\"data\":[{\"age\":80,\"contractStatus\":\"生效中\",\"customerId\":\"BW757133\",\"customerName\":\"於玉敏\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-07\",\"phoneNumber\":\"13818977776\",\"sex\":\"女\",\"signDate\":\"2025-02-08\",\"startDate\":\"2025-02-08\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":86,\"contractStatus\":\"失效\",\"customerId\":\"BW795778\",\"customerName\":\"金聘芳\",\"deptId\":\"BW21\",\"endDate\":\"2025-04-18\",\"phoneNumber\":\"13371946969\",\"sex\":\"女\",\"signDate\":\"2025-04-01\",\"startDate\":\"2025-04-01\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":92,\"contractStatus\":\"生效中\",\"customerId\":\"BW952026\",\"customerName\":\"吕煜楚\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-22\",\"phoneNumber\":\"13066742401\",\"sex\":\"男\",\"signDate\":\"2025-08-17\",\"startDate\":\"2025-08-23\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":93,\"contractStatus\":\"生效中\",\"customerId\":\"BW952028\",\"customerName\":\"陈铨铃\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-22\",\"phoneNumber\":\"13066742401\",\"sex\":\"女\",\"signDate\":\"2025-08-17\",\"startDate\":\"2025-08-23\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":88,\"contractStatus\":\"生效中\",\"customerId\":\"BW812861\",\"customerName\":\"周维明\",\"deptId\":\"BW21\",\"endDate\":\"2026-04-20\",\"phoneNumber\":\"18939863799\",\"sex\":\"男\",\"signDate\":\"2025-04-15\",\"startDate\":\"2025-04-21\",\"userId\":\"BW104\",\"userName\":\"程亮\"},{\"age\":75,\"contractStatus\":\"生效中\",\"customerId\":\"BW850567\",\"customerName\":\"蒋金良\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-19\",\"phoneNumber\":\"13902991594\",\"sex\":\"男\",\"signDate\":\"2025-05-20\",\"startDate\":\"2025-05-20\",\"userId\":\"BW190\",\"userName\":\"孙珺\"},{\"age\":75,\"contractStatus\":\"生效中\",\"customerId\":\"BW850568\",\"customerName\":\"董玉珍\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-19\",\"phoneNumber\":\"18017723051\",\"sex\":\"女\",\"signDate\":\"2025-05-20\",\"startDate\":\"2025-05-20\",\"userId\":\"BW190\",\"userName\":\"孙珺\"},{\"age\":79,\"contractStatus\":\"生效中\",\"customerId\":\"BW873200\",\"customerName\":\"李天兰\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-27\",\"phoneNumber\":\"13585562601\",\"sex\":\"女\",\"signDate\":\"2025-06-28\",\"startDate\":\"2025-06-28\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":81,\"contractStatus\":\"生效中\",\"customerId\":\"BW767197\",\"customerName\":\"王扣红\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-13\",\"phoneNumber\":\"13917070797\",\"sex\":\"女\",\"signDate\":\"2025-02-09\",\"startDate\":\"2025-02-14\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":84,\"contractStatus\":\"生效中\",\"customerId\":\"BW846180\",\"customerName\":\"王巧珍\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-28\",\"phoneNumber\":\"18918051951\",\"sex\":\"女\",\"signDate\":\"2025-05-29\",\"startDate\":\"2025-05-29\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":89,\"contractStatus\":\"生效中\",\"customerId\":\"BW872905\",\"customerName\":\"顾玲凤\",\"deptId\":\"BW21\",\"endDate\":\"2026-07-31\",\"phoneNumber\":\"18821067869\",\"sex\":\"女\",\"signDate\":\"2025-07-24\",\"startDate\":\"2025-08-01\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":92,\"contractStatus\":\"生效中\",\"customerId\":\"BW786365\",\"customerName\":\"孙素娥\",\"deptId\":\"BW21\",\"endDate\":\"2026-03-12\",\"phoneNumber\":\"13524548017\",\"sex\":\"女\",\"signDate\":\"2025-03-13\",\"startDate\":\"2025-03-13\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":88,\"contractStatus\":\"生效中\",\"customerId\":\"BW843807\",\"customerName\":\"苏耀春\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-27\",\"phoneNumber\":\"18964997883\",\"sex\":\"男\",\"signDate\":\"2025-05-28\",\"startDate\":\"2025-05-28\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":81,\"contractStatus\":\"生效中\",\"customerId\":\"BW771552\",\"customerName\":\"王永芳\",\"deptId\":\"BW21\",\"endDate\":\"2026-03-15\",\"phoneNumber\":\"15300798909\",\"sex\":\"女\",\"signDate\":\"2025-02-18\",\"startDate\":\"2025-03-16\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":84,\"contractStatus\":\"生效中\",\"customerId\":\"BW767185\",\"customerName\":\"王孝全\",\"deptId\":\"BW21\",\"endDate\":\"2026-04-01\",\"phoneNumber\":\"18930407155\",\"sex\":\"男\",\"signDate\":\"2025-03-16\",\"startDate\":\"2025-04-02\",\"userId\":\"BW362\",\"userName\":\"薛佳莹\"},{\"age\":86,\"contractStatus\":\"生效中\",\"customerId\":\"BW769241\",\"customerName\":\"王远景\",\"deptId\":\"BW21\",\"endDate\":\"2026-03-11\",\"phoneNumber\":\"13601695927\",\"sex\":\"男\",\"signDate\":\"2025-02-19\",\"startDate\":\"2025-03-12\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":74,\"contractStatus\":\"生效中\",\"customerId\":\"BW941039\",\"customerName\":\"施玉花\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-16\",\"phoneNumber\":\"18217504801\",\"sex\":\"女\",\"signDate\":\"2025-08-17\",\"startDate\":\"2025-08-17\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":86,\"contractStatus\":\"生效中\",\"customerId\":\"BW847841\",\"customerName\":\"郑迪辉\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-27\",\"phoneNumber\":\"18964997883\",\"sex\":\"女\",\"signDate\":\"2025-05-28\",\"startDate\":\"2025-05-28\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":78,\"contractStatus\":\"生效中\",\"customerId\":\"BW933897\",\"customerName\":\"倪秀珍\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-17\",\"phoneNumber\":\"19229820650\",\"sex\":\"女\",\"signDate\":\"2025-08-18\",\"startDate\":\"2025-08-18\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":90,\"contractStatus\":\"生效中\",\"customerId\":\"BW852723\",\"customerName\":\"陈丽莲\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-31\",\"phoneNumber\":\"13801692532\",\"sex\":\"女\",\"signDate\":\"2025-05-27\",\"startDate\":\"2025-06-01\",\"userId\":\"BW190\",\"userName\":\"孙珺\"},{\"age\":90,\"contractStatus\":\"生效中\",\"customerId\":\"BW757056\",\"customerName\":\"顾金炎\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-05\",\"phoneNumber\":\"13601235613\",\"sex\":\"女\",\"signDate\":\"2025-02-06\",\"startDate\":\"2025-02-06\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":90,\"contractStatus\":\"生效中\",\"customerId\":\"BW907122\",\"customerName\":\"邵味薇\",\"deptId\":\"BW21\",\"endDate\":\"2026-07-31\",\"phoneNumber\":\"13621602188\",\"sex\":\"女\",\"signDate\":\"2025-07-16\",\"startDate\":\"2025-08-01\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":76,\"contractStatus\":\"失效\",\"customerId\":\"BW752722\",\"customerName\":\"江则理\",\"deptId\":\"BW21\",\"endDate\":\"2025-06-06\",\"phoneNumber\":\"15652642981\",\"sex\":\"男\",\"signDate\":\"2025-02-01\",\"startDate\":\"2025-02-01\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":72,\"contractStatus\":\"失效\",\"customerId\":\"BW752721\",\"customerName\":\"鹿丽丽\",\"deptId\":\"BW21\",\"endDate\":\"2025-06-06\",\"phoneNumber\":\"15652642981\",\"sex\":\"女\",\"signDate\":\"2025-02-01\",\"startDate\":\"2025-02-01\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":65,\"contractStatus\":\"失效\",\"customerId\":\"BW766551\",\"customerName\":\"鲍敏娟\",\"deptId\":\"BW21\",\"endDate\":\"2025-05-06\",\"phoneNumber\":\"13061762696\",\"sex\":\"女\",\"signDate\":\"2025-02-21\",\"startDate\":\"2025-02-21\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":82,\"contractStatus\":\"失效\",\"customerId\":\"BW804789\",\"customerName\":\"黄晔如\",\"deptId\":\"BW21\",\"endDate\":\"2025-04-16\",\"phoneNumber\":\"18967252951\",\"sex\":\"女\",\"signDate\":\"2025-03-30\",\"startDate\":\"2025-05-30\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":82,\"contractStatus\":\"失效\",\"customerId\":\"BW804788\",\"customerName\":\"金锡志\",\"deptId\":\"BW21\",\"endDate\":\"2025-04-16\",\"phoneNumber\":\"13818820955\",\"sex\":\"男\",\"signDate\":\"2025-03-30\",\"startDate\":\"2025-05-30\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":79,\"contractStatus\":\"生效中\",\"customerId\":\"BW764847\",\"customerName\":\"洪洁\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-14\",\"phoneNumber\":\"13608250326\",\"sex\":\"女\",\"signDate\":\"2025-02-14\",\"startDate\":\"2025-02-15\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":90,\"contractStatus\":\"失效\",\"customerId\":\"BW645689\",\"customerName\":\"万国华\",\"deptId\":\"BW21\",\"endDate\":\"2025-02-13\",\"phoneNumber\":\"13816133533\",\"sex\":\"女\",\"signDate\":\"2025-01-06\",\"startDate\":\"2025-01-08\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":68,\"contractStatus\":\"生效中\",\"customerId\":\"BW948657\",\"customerName\":\"周承浩\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-27\",\"phoneNumber\":\"18116170849\",\"sex\":\"男\",\"signDate\":\"2025-08-21\",\"startDate\":\"2025-08-28\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":83,\"contractStatus\":\"失效\",\"customerId\":\"BW846267\",\"customerName\":\"王寒清\",\"deptId\":\"BW21\",\"endDate\":\"2025-05-27\",\"phoneNumber\":\"15000351747\",\"sex\":\"女\",\"signDate\":\"2025-05-30\",\"startDate\":\"2025-05-30\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":86,\"contractStatus\":\"失效\",\"customerId\":\"BW752614\",\"customerName\":\"王秉杰\",\"deptId\":\"BW21\",\"endDate\":\"2025-02-09\",\"phoneNumber\":\"13917070797\",\"sex\":\"男\",\"signDate\":\"2025-02-09\",\"startDate\":\"2025-02-14\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":91,\"contractStatus\":\"生效中\",\"customerId\":\"BW913355\",\"customerName\":\"仇盛德\",\"deptId\":\"BW21\",\"endDate\":\"2026-07-31\",\"phoneNumber\":\"13621602188\",\"sex\":\"男\",\"signDate\":\"2025-07-16\",\"startDate\":\"2025-08-01\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":80,\"contractStatus\":\"生效中\",\"customerId\":\"BW794336\",\"customerName\":\"郑美芳\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-08\",\"phoneNumber\":\"13917266530\",\"sex\":\"女\",\"signDate\":\"2025-05-06\",\"startDate\":\"2025-05-09\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":96,\"contractStatus\":\"生效中\",\"customerId\":\"BW849545\",\"customerName\":\"邵国民\",\"deptId\":\"BW21\",\"endDate\":\"2026-04-22\",\"phoneNumber\":\"18016276945\",\"sex\":\"男\",\"signDate\":\"2025-05-23\",\"startDate\":\"2025-05-23\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":76,\"contractStatus\":\"生效中\",\"customerId\":\"BW827892\",\"customerName\":\"蔡超眉\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-14\",\"phoneNumber\":\"18001876005\",\"sex\":\"女\",\"signDate\":\"2025-05-05\",\"startDate\":\"2025-05-15\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":88,\"contractStatus\":\"生效中\",\"customerId\":\"BW849546\",\"customerName\":\"赵文娟\",\"deptId\":\"BW21\",\"endDate\":\"2026-04-22\",\"phoneNumber\":\"13651650034\",\"sex\":\"女\",\"signDate\":\"2025-05-23\",\"startDate\":\"2025-05-23\",\"userId\":\"BW1334\",\"userName\":\"陈学军\"},{\"age\":76,\"contractStatus\":\"生效中\",\"customerId\":\"BW827891\",\"customerName\":\"陈富华\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-14\",\"phoneNumber\":\"13061948503\",\"sex\":\"男\",\"signDate\":\"2025-05-05\",\"startDate\":\"2025-05-15\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":85,\"contractStatus\":\"失效\",\"customerId\":\"BW797848\",\"customerName\":\"管宝妹\",\"deptId\":\"BW21\",\"endDate\":\"2025-04-16\",\"phoneNumber\":\"13501806976\",\"sex\":\"女\",\"signDate\":\"2025-03-31\",\"startDate\":\"2025-05-11\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":89,\"contractStatus\":\"生效中\",\"customerId\":\"BW979450\",\"customerName\":\"张婉予\",\"deptId\":\"BW21\",\"endDate\":\"2026-09-16\",\"phoneNumber\":\"15317613530\",\"sex\":\"女\",\"signDate\":\"2025-09-17\",\"startDate\":\"2025-09-17\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":80,\"contractStatus\":\"生效中\",\"customerId\":\"BW848540\",\"customerName\":\"金和基\",\"deptId\":\"BW21\",\"endDate\":\"2027-05-30\",\"phoneNumber\":\"13641803044\",\"sex\":\"男\",\"signDate\":\"2025-05-31\",\"startDate\":\"2025-05-31\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":90,\"contractStatus\":\"失效\",\"customerId\":\"BW843658\",\"customerName\":\"马旭\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-21\",\"phoneNumber\":\"13681898526\",\"sex\":\"男\",\"signDate\":\"2025-05-22\",\"startDate\":\"2025-05-22\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":89,\"contractStatus\":\"生效中\",\"customerId\":\"BW757084\",\"customerName\":\"奚振邦\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-05\",\"phoneNumber\":\"13601912216\",\"sex\":\"男\",\"signDate\":\"2025-02-06\",\"startDate\":\"2025-02-06\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":67,\"contractStatus\":\"生效中\",\"customerId\":\"BW949498\",\"customerName\":\"李晓星\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-27\",\"phoneNumber\":\"18116170849\",\"sex\":\"女\",\"signDate\":\"2025-08-21\",\"startDate\":\"2025-08-28\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":71,\"contractStatus\":\"生效中\",\"customerId\":\"BW814881\",\"customerName\":\"张碧兰\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-19\",\"phoneNumber\":\"18003897493\",\"sex\":\"女\",\"signDate\":\"2025-06-20\",\"startDate\":\"2025-06-20\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":79,\"contractStatus\":\"生效中\",\"customerId\":\"BW767206\",\"customerName\":\"陆美芳\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-28\",\"phoneNumber\":\"13601609182\",\"sex\":\"女\",\"signDate\":\"2025-02-27\",\"startDate\":\"2025-03-01\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":79,\"contractStatus\":\"生效中\",\"customerId\":\"BW878619\",\"customerName\":\"苏迺秦\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-27\",\"phoneNumber\":\"13585562601\",\"sex\":\"男\",\"signDate\":\"2025-06-28\",\"startDate\":\"2025-06-28\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":84,\"contractStatus\":\"生效中\",\"customerId\":\"BW727467\",\"customerName\":\"包素茵\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-31\",\"phoneNumber\":\"13661670719\",\"sex\":\"女\",\"signDate\":\"2025-01-03\",\"startDate\":\"2025-02-01\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":71,\"contractStatus\":\"生效中\",\"customerId\":\"BW814438\",\"customerName\":\"张子庆\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-19\",\"phoneNumber\":\"18003897493\",\"sex\":\"男\",\"signDate\":\"2025-06-20\",\"startDate\":\"2025-06-20\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":77,\"contractStatus\":\"生效中\",\"customerId\":\"BW695423\",\"customerName\":\"李秀英\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-14\",\"phoneNumber\":\"18930786217\",\"sex\":\"女\",\"signDate\":\"2025-01-15\",\"startDate\":\"2025-01-15\",\"userId\":\"BW129\",\"userName\":\"陆敏\"},{\"age\":85,\"contractStatus\":\"生效中\",\"customerId\":\"BW767903\",\"customerName\":\"金国珍\",\"deptId\":\"BW21\",\"endDate\":\"2026-04-30\",\"phoneNumber\":\"13901707213\",\"sex\":\"女\",\"signDate\":\"2025-05-01\",\"startDate\":\"2025-05-01\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":81,\"contractStatus\":\"生效中\",\"customerId\":\"BW848538\",\"customerName\":\"王文君\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-25\",\"phoneNumber\":\"13917389371\",\"sex\":\"女\",\"signDate\":\"2025-05-23\",\"startDate\":\"2025-05-26\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":86,\"contractStatus\":\"生效中\",\"customerId\":\"BW848536\",\"customerName\":\"周世福\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-25\",\"phoneNumber\":\"13817254818\",\"sex\":\"男\",\"signDate\":\"2025-05-23\",\"startDate\":\"2025-05-26\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":71,\"contractStatus\":\"生效中\",\"customerId\":\"BW871409\",\"customerName\":\"HUANG/JULIE MIN-YING\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-19\",\"phoneNumber\":\"13127925768\",\"sex\":\"女\",\"signDate\":\"2025-06-20\",\"startDate\":\"2025-06-20\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":82,\"contractStatus\":\"生效中\",\"customerId\":\"BW773703\",\"customerName\":\"任小多\",\"deptId\":\"BW21\",\"endDate\":\"2026-02-14\",\"phoneNumber\":\"13608250326\",\"sex\":\"男\",\"signDate\":\"2025-02-14\",\"startDate\":\"2025-02-15\",\"userId\":\"BW128\",\"userName\":\"居莉\"},{\"age\":84,\"contractStatus\":\"生效中\",\"customerId\":\"BW936756\",\"customerName\":\"吴玲娣\",\"deptId\":\"BW21\",\"endDate\":\"2026-08-06\",\"phoneNumber\":\"13002109013\",\"sex\":\"女\",\"signDate\":\"2025-08-04\",\"startDate\":\"2025-08-07\",\"userId\":\"BW104\",\"userName\":\"程亮\"},{\"age\":78,\"contractStatus\":\"生效中\",\"customerId\":\"BW725566\",\"customerName\":\"朱锦芳\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-18\",\"phoneNumber\":\"15301890232\",\"sex\":\"女\",\"signDate\":\"2025-01-19\",\"startDate\":\"2025-01-19\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":75,\"contractStatus\":\"生效中\",\"customerId\":\"BW947955\",\"customerName\":\"彭长香\",\"deptId\":\"BW21\",\"endDate\":\"2026-09-03\",\"phoneNumber\":\"18017080805\",\"sex\":\"女\",\"signDate\":\"2025-08-25\",\"startDate\":\"2025-09-04\",\"userId\":\"BW362\",\"userName\":\"薛佳莹\"},{\"age\":90,\"contractStatus\":\"生效中\",\"customerId\":\"BW735676\",\"customerName\":\"尤合群\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-12\",\"phoneNumber\":\"18017832956\",\"sex\":\"男\",\"signDate\":\"2025-01-06\",\"startDate\":\"2025-01-13\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":86,\"contractStatus\":\"生效中\",\"customerId\":\"BW735677\",\"customerName\":\"曹静芝\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-12\",\"phoneNumber\":\"18017832956\",\"sex\":\"女\",\"signDate\":\"2025-01-06\",\"startDate\":\"2025-01-13\",\"userId\":\"BW1333\",\"userName\":\"孙婷\"},{\"age\":79,\"contractStatus\":\"生效中\",\"customerId\":\"BW853993\",\"customerName\":\"唐美珍\",\"deptId\":\"BW21\",\"endDate\":\"2026-05-29\",\"phoneNumber\":\"13564017632\",\"sex\":\"女\",\"signDate\":\"2025-05-30\",\"startDate\":\"2025-05-30\",\"userId\":\"BW301\",\"userName\":\"张曼华\"},{\"age\":74,\"contractStatus\":\"生效中\",\"customerId\":\"BW892410\",\"customerName\":\"梁毅英\",\"deptId\":\"BW21\",\"endDate\":\"2026-09-07\",\"phoneNumber\":\"15021969288\",\"sex\":\"男\",\"signDate\":\"2025-09-08\",\"startDate\":\"2025-09-08\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":76,\"contractStatus\":\"生效中\",\"customerId\":\"BW732186\",\"customerName\":\"叶崇莺\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-31\",\"phoneNumber\":\"13651798609\",\"sex\":\"女\",\"signDate\":\"2025-02-01\",\"startDate\":\"2025-02-01\",\"userId\":\"BW302\",\"userName\":\"陈洁\"},{\"age\":88,\"contractStatus\":\"生效中\",\"customerId\":\"BW855020\",\"customerName\":\"张乐怡\",\"deptId\":\"BW21\",\"endDate\":\"2026-06-08\",\"phoneNumber\":\"13801640221\",\"sex\":\"女\",\"signDate\":\"2025-06-09\",\"startDate\":\"2025-06-09\",\"userId\":\"BW104\",\"userName\":\"程亮\"},{\"age\":92,\"contractStatus\":\"生效中\",\"customerId\":\"BW745496\",\"customerName\":\"赵秋枫\",\"deptId\":\"BW21\",\"endDate\":\"2026-01-22\",\"phoneNumber\":\"13817872321\",\"sex\":\"男\",\"signDate\":\"2025-01-15\",\"startDate\":\"2025-01-23\",\"userId\":\"BW362\",\"userName\":\"薛佳莹\"}]}";
		//return st;
		String url = SINGN_USER+"?currentUserId="+currentUserId+"&currentDeptId="+currentDeptId;
		String key = SINGN_USER;
		if(StringUtils.isNotBlank(startDate)) {
			url = url+"&startDate="+startDate;
			key = key+"&startDate="+startDate;
		}
		if(StringUtils.isNotBlank(endDate)) {
			url = url+"&endDate="+endDate;
			key = key+"&endDate="+endDate;
		}
		if(!CollectionUtils.isEmpty(deptIds)) {
			url = url+"&deptIds="+String.join(",", deptIds);
			key = key+"&deptIds="+String.join(",", deptIds);
		}
		String resp = (String)redisClient.get(key);
		if(StringUtils.isBlank(resp)) {
			resp = requestManageService.getMethod(url, String.class);
			redisClient.set(key, resp, 2*60*60);
		}
		return resp;
	}
}
